/**
 * Candidate number: 35834
 */
package tv.starfu.systems.level;

import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.EntityProcessingSystem;
import com.artemis.IntervalEntityProcessingSystem;
import tv.starfu.components.level.Compass;
import tv.starfu.components.level.GridPosition;
import tv.starfu.components.level.Path;
import tv.starfu.components.Transform;
import tv.starfu.components.level.KyberneteGrid;

/**
 * KyberGridPosition gives each Tile a coordinate in the grid.
 * Compass gives each tile four doorways
 * Path determines a traversable pathway in zeroes and ones, based on Compass.
 * * Split each Tile into 16 Cells, Cells are either traversable or they're not.
 * @author nia radical
 */
public class TileSystem extends IntervalEntityProcessingSystem {

    private boolean isGenerated;
    
    
    private ComponentMapper<KyberneteGrid> kyberGridMapper;
    private ComponentMapper<GridPosition> kyberGridPosMapper;
    private ComponentMapper<Compass> compassMapper;    
    private ComponentMapper<Path> pathMapper;
    
    private ComponentMapper<Transform> positioningMapper;
    
    private int[] cells;
    
    
    public TileSystem() {
        super(10,Transform.class, GridPosition.class, Compass.class, Path.class);
    }
    
    @Override
    public void initialize() {
        //positioningMapper = new ComponentMapper<Transform>(Transform.class, world);
        kyberGridPosMapper = new ComponentMapper<GridPosition>(GridPosition.class, world);
        compassMapper = new ComponentMapper<Compass>(Compass.class, world);
        pathMapper = new ComponentMapper<Path>(Path.class, world);
        System.out.println("TileSystem initialising");
    }
    

    @Override
    protected void process(Entity e) {
        // Get components from each entity
        if(!isGenerated) {
            
        }
        System.out.println("Tile System : getting components from Tile entities { KyberGridPos, Transform, Path, Compass }");
        GridPosition kyberGridPos = kyberGridPosMapper.get(e);
        Transform positioning = positioningMapper.get(e);
        Path path = pathMapper.get(e);
        Compass compass = compassMapper.get(e);
        
        // Get tile size and position
        System.out.println("Tile System : get KyberGridPosition");;
        int xPos = kyberGridPos.x+1;
        int yPos = kyberGridPos.y+1;
        
        // Set positioning to multiple of tile size
      //  positioning.position.x = xPos*4;
      //  positioning.position.y = yPos*4;
        System.out.println("Herro from TileSystemProcessor");
        

            
    }
    
}
